package com.qf.servlet; /**
 * @author lixu
 */

import com.qf.pojo.Emp;
import com.qf.service.EmpService;
import com.qf.service.EmpServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/empServlet")
public class EmpServlet extends HttpServlet {

 /*   private EmpService empService;
    public void setEmpService(EmpService empService) {
        this.empService = empService;
    }*/

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       //临时方案 ： SpringMVC还没有学习
        ApplicationContext ac  =
                new ClassPathXmlApplicationContext("spring-context.xml");
        EmpServiceImpl empService = ac.getBean(EmpServiceImpl.class);
        List<Emp> empList = empService.findAll();
        empList.forEach(System.out::println);
        
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
